package controllers;

import java.io.IOException;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.mongodb.BasicDBObject;
import com.mongodb.DBCollection;
import com.mongodb.DBCursor;

import data.Data;

@SuppressWarnings("serial")
public class CheckRegServlet extends HttpServlet {
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws IOException {
		
		String sitemap = request.getParameter("sitemap");
		String type = request.getParameter("type");
		
		DBCollection collection = Data.data("urlCraw");
		
		DBCursor cursor = collection.find(new BasicDBObject("domain",Utils.fomatDmain(sitemap)).append("type", type)).limit(10);
		
		request.setAttribute("cursor", cursor);
		
		try {
			request.getRequestDispatcher("/check_reg.jsp").forward(request, response);
		} catch (Exception e) {
			// TODO: handle exception
		}
	}
}
